package com.cy.pj.common.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;


@Component
@Slf4j
@Aspect
public class SysExceptionAspect {
    /**
     * 定义sysUserServiceImpl实现类异常的监控切面,并以日志信息输出
     * 不会截断异常
     */
    @AfterThrowing(value = "bean(sysUserServiceImpl)",throwing = "ex")
    public void doLogException(JoinPoint jp, Exception ex){
        //获取目标方法签名
        MethodSignature ms = (MethodSignature)jp.getSignature();
        log.error("{} SysExceptionAspect.exception {}",ms.getMethod(), ex.getMessage());
    }
}
